<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
 <%@ page import="utility.UserSession" %>
<%@ page import= "java.sql.ResultSet" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Game Score Display</title>
</head>
<body>
<div id="e">
<p><a href="/QSS"><font color=#4682B4>Logout</font></a></p></div>
<div id="c"><b>Score Board for ${Topic} Quiz</b><br><br>
<%
System.out.println(request.getSession().getAttribute("score"));
Integer score = (Integer)(request.getSession().getAttribute("score"));
 System.out.println(score);
// int score = Integer.parseInt(str);
int wrongAnswerCount = 10-score;
float percentage = (score/(float)(10))*100;
%>
<b><font color="DarkOliveGreen">Number of Correct answers: <%=score %><br>
Number of Wrong ansers:<%=wrongAnswerCount %><br>
Percentage Correct: <%=percentage%>%<br><br><br></font></b>
<%
String userID = (String)request.getSession().getAttribute("userID");
//Updating ScoreBoard
ResultSet result = UserSession.getScoreInfo(userID);
if(result.next())
{
int currentScore = result.getInt("NumCorrectQues");
int attemptedQues = result.getInt("NumAttemptedQues");
int totalQuizes = result.getInt("TotalQuizNum");
currentScore+=score;
attemptedQues+=10;
totalQuizes++;
float overallscore = (currentScore/(float)attemptedQues)*100;
UserSession.updateScoreBoard(userID, overallscore, currentScore, attemptedQues, totalQuizes, score);
}
else
{
	UserSession.updateScoreBoard(userID, percentage, score, 10, 1, score);
}
//Updating questionAttempted
%>
<input type="button" class="button" value = "User Home" onClick = "window.location = 'UserHome.jsp'" style = "height:35px; width:100px" >&nbsp;&nbsp;
<!-- <input type="button" class="button" value = "Share Scores" onClick = "window.location = 'Scoreboard.jsp'" style = "height:35px; width:100px" ><br><br> -->
</div>
</body>
</html>